package com.paradise.sharding;

import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

public class MyBatisPlusGenerator {
    public static void main(String[] args) {
        final AutoGenerator generator = new AutoGenerator();
        DataSourceConfig dataSourceConfig = new DataSourceConfig();
        dataSourceConfig.setUrl("jdbc:mysql://192.168.1.104:3306/eth_analyzer");
        dataSourceConfig.setDriverName("com.mysql.jdbc.Driver");
        dataSourceConfig.setUsername("root");
        dataSourceConfig.setPassword("XnxDF1RnyxJuswcn");

        String projectPath = System.getProperty("user.dir");

        StrategyConfig strategyConfig = new StrategyConfig();
        strategyConfig.setTablePrefix("t_");
        strategyConfig.setNaming(NamingStrategy.underline_to_camel);


        GlobalConfig globalConfig = new GlobalConfig();
        globalConfig.setOutputDir(projectPath + "/src/main/java");
        globalConfig.setOpen(false);
        globalConfig.setAuthor("Paradise");

        PackageConfig packageConfig = new PackageConfig();
        packageConfig.setModuleName("eth");
        packageConfig.setParent("com.paradise.sharding");
        packageConfig.setServiceImpl("service");

        generator.setDataSource(dataSourceConfig);
        generator.setStrategy(strategyConfig);
        generator.setGlobalConfig(globalConfig);
        generator.setPackageInfo(packageConfig);

        generator.execute();
    }
}
